package cn.hesion.designpattern.StrategyPattern.Pay.payPort;

import java.util.HashMap;
import java.util.Map;

public class PayStrategy {
    public static final String AlI_PAY = "AliPay";
    public static final String WECHAT_PAY = "Wechat_Pay";
    public static final String DEFAULT_PAY = AlI_PAY;
    private static Map<String, PayMent> payStrategy = new HashMap<>();

    static {
        payStrategy.put(AlI_PAY, new AliPay());
        payStrategy.put(WECHAT_PAY, new WePay());
    }

    public static PayMent get(String keyPay){
        if(!payStrategy.containsKey(keyPay)){
            return payStrategy.get(DEFAULT_PAY);
        }
        return payStrategy.get(keyPay);
    }
}
